/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.h
  * @brief          : Header for main.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2024 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx_hal.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */
#define BUFF_MAX_Size 1024
typedef struct{
    uint8_t startflag;
    uint8_t recflag;
    uint32_t reclen;
    uint16_t overtime;
    uint8_t  overtimeflag;
    uint8_t data[BUFF_MAX_Size];
}RecData;

#define BUFF_SIZE 256
enum{
    COM_START_BIT,  //起始�??????????
    COM_D0_BIT,     //bit0
    COM_D1_BIT,     //bit1
    COM_D2_BIT,     //bit2
    COM_D3_BIT,     //bit3
    COM_D4_BIT,     //bit4
    COM_D5_BIT,     //bit5
    COM_D6_BIT,     //bit6
    COM_D7_BIT,     //bit7
    COM_STOP_BIT,   //bit8
};
/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
#define KEY_Pin GPIO_PIN_0
#define KEY_GPIO_Port GPIOA
#define LCD_TX_Pin GPIO_PIN_2
#define LCD_TX_GPIO_Port GPIOA
#define LCD_RX_Pin GPIO_PIN_3
#define LCD_RX_GPIO_Port GPIOA
#define LED_Pin GPIO_PIN_12
#define LED_GPIO_Port GPIOB
#define TX_Pin GPIO_PIN_11
#define TX_GPIO_Port GPIOA
#define RX_Pin GPIO_PIN_12
#define RX_GPIO_Port GPIOA
#define RX_EXTI_IRQn EXTI15_10_IRQn

/* USER CODE BEGIN Private defines */
#define Set_TX(a) HAL_GPIO_WritePin(TX_GPIO_Port,TX_Pin,a?GPIO_PIN_SET:GPIO_PIN_RESET)
#define Get_RX()  HAL_GPIO_ReadPin(RX_GPIO_Port,RX_Pin)
#define ReadKey() HAL_GPIO_ReadPin(KEY_GPIO_Port,KEY_Pin)
extern void os_printf(const char *format, ...);
extern void lcd_printf(const char *format, ...);
extern void send_byte(uint8_t data);
extern void send_buff(uint8_t *buf,uint32_t len);
extern void TIM_Cmd(FunctionalState mode);
extern void RXCMD(FunctionalState mode);
extern RecData MyUartRec;
extern uint8_t RecvState;
extern uint8_t  MyRecData;
extern void CanSendData(uint8_t id,uint8_t cmd);
/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */
